package com.bookmall.cart.controller;

import com.bookmall.cart.domain.Cart;
import com.bookmall.cart.service.ICartService;
import com.ruoyi.common.core.web.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description:
 * @Author 胡菜鸡
 * @Create 2022-04-28-17:30
 */
@RestController
@RequestMapping("/cart/info")
public class CartInfoController {
    @Autowired
    private ICartService cartService;
    /**
     * 获取购物车中登录会员的购物项数据
     * @author 胡菜鸡
     * @date 2022/4/28 17:32
     */
    @PreAuthorize("@ss.hasPermi('cart:info:query')")
    @GetMapping("/loginMember")
    public AjaxResult getCartInfoByLoginMember(){
        Cart cart = cartService.getCartInfoByLoginMember();
        if(cart == null){
            return AjaxResult.error();
        }
        return AjaxResult.success(cart);
    }
}
